<template>
  <div>
    <van-tabbar fixed route placeholder v-model="active" @change="handleChange">
      <van-tabbar-item replace v-for="(item, index) in data" :key="item.title + index" :to="item.to">
        <span>{{ item.title }}</span>
        <template #icon="props">
          <img :src="props.active ? item.icon.active : item.icon.inactive" />
        </template>
      </van-tabbar-item>
    </van-tabbar>
  </div>
</template>
<script>
export default {
  name: 'Tabbar',
  props: {
    defaultActive: {
      type: Number,
      default: 1
    },
    data: {
      type: Array,
      default: () => {
        return []
      }
    }
  },
  data() {
    return {
      active: this.defaultActive
    }
  },
  methods: {
    handleChange(value) {
      this.$emit('change', value)
    }
  }
}
</script>

<style lang="less">
@import '../assets/css/modifyVant.less';
</style>
